package br.usp.pcs.basys2.event;

import java.util.Calendar;

import br.usp.pcs.basys2.BasysProcess;
import br.usp.pcs.basys2.engine.Engine;

public class RequestMemoryEvent extends Event {
	
	private final boolean advanceProcessorQueue;

	public RequestMemoryEvent(BasysProcess process, Calendar dateOfArrival, boolean advanceProcessorQueue) {
		super(process, dateOfArrival);
		this.advanceProcessorQueue = advanceProcessorQueue;
	}

	@Override
	public void execute() {
		Engine engine = Engine.getInstance();
		engine.getSystem().getMemoryManager().manage(this.getProcess());
		if (advanceProcessorQueue){
			engine.getSystem().getProcessorManager().advanceQueue();
		}
	}

}
